package games.hearthstone;


public class PackToDust {

	public static void main(String[] args) {

		int totalPacks = 1000000;
		int max = 0;
		int min = Integer.MAX_VALUE;
		int totalDust = 0;
//		Map<Integer, Integer> dustCount = new HashMap<Integer, Integer>();

		for (int i = 0; i < totalPacks; i++) {
			Card[] cardPack = new Card[Constants.cardsPerPack];
			for (int j = 0; j < cardPack.length; j++) {
				cardPack[j] = HSUtils.getRandomCard();
			}

			while (allCommon(cardPack)) {
				cardPack[0] = HSUtils.getRandomCard();
			}

			int totalPackDust = 0;
			for (int j = 0; j < cardPack.length; j++) {
				totalPackDust+=HSUtils.convertToDust(cardPack[j]);
			}

//			if (dustCount.containsKey(totalPackDust)) {
//				dustCount.put(totalPackDust, dustCount.get(totalPackDust) + 1);
//			} else {
//				dustCount.put(totalPackDust, 1);
//			}

			max = Math.max(max, totalPackDust);
			min = Math.min(min, totalPackDust);
			totalDust+=totalPackDust;
		}

		System.out.println("min " + min);
		System.out.println("avg " + (float)totalDust/totalPacks);
		System.out.println("max " + max);

//		List<Pair<Integer, Integer>> sortedDust = new ArrayList<Pair<Integer,Integer>>(dustCount.size());
//		for (Entry<Integer, Integer> pair : dustCount.entrySet()) {
//			sortedDust.add(new Pair<Integer, Integer>(pair.getKey(), pair.getValue()));
//		}
//		Collections.sort(sortedDust, new Comparator<Pair<Integer, Integer>>() {
//			@Override
//			public int compare(Pair<Integer, Integer> o1, Pair<Integer, Integer> o2) {
//				return o1.getFirst().compareTo(o2.getFirst());
//			}
//		});
//
//		for (Pair<Integer, Integer> pair : sortedDust) {
//			System.out.println(pair.getFirst() + "\t\t" + pair.getSecond());
//		}
	}

	private static boolean allCommon(Card[] cardPack) {
		for (int j = 0; j < cardPack.length; j++) {
			if (!cardPack[j].getRarity().equals(Rarity.Common)) {
				return false;
			}
		}
		return true;
	}

}
